package com.scau.service.impl.business;

import java.io.Serializable;

import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.scau.exception.BusinessException;
import com.scau.model.business.Purchase;
import com.scau.model.business.PurchaseDetail;
import com.scau.service.BaseService;
@Component
public class PurchaseDetailService extends BaseService<PurchaseDetail> implements Serializable{
	@Transactional
	public void  save(PurchaseDetail purchaseDetail)throws BusinessException {
		if(null != purchaseDetail ){
			if(null != purchaseDetail.getId() && 0 != purchaseDetail.getId()){
				update(purchaseDetail);
			}
			else{
				add(purchaseDetail);
			}
		}
		else {
			throw new BusinessException("采购单明细ID不能为空");
		}
	}
	
	@Override
	public PurchaseDetail get(PurchaseDetail entity){
		if(null!=entity&&null!=entity.getId()&&0!=entity.getId()){
			return super.get(entity, entity.getId());
		}else if (null!=entity) {
			return super.get(entity);
		}else {
			return null;
		}
	}
	
}
